// topBar中的分享组件
import { Alert, Share, StyleSheet, Text, View } from 'react-native'
import React from 'react'
import Icon from 'react-native-vector-icons/FontAwesome'

const ShareCom = () => {
  const userShare = async () => {
    console.log('12');
    Share.share({
      message: '这是分享的数据',
      title: '我是title',
      Content: '分享的内容',
      url: 'https://www.baidu.com'
    }, {
      dialogTitle: '想要分享的平台'
    }).then(res => {
      console.log('分享的结果：', res.action, 'Share.sharedAction:', Share.sharedAction);
      if (res.action === Share.sharedAction) {
        console.log('分享成功', res.activityType);
        if (res.activityType) {
          Alert.alert('', `成功分享到${res.activityType}`)
        } else {
          Alert.alert('', '分享成功')
        }
      } else if (res.action === Share.dismissedAction) {
        console.log('分享失败');
      }
    }).catch(err => console.log('err:', err))
  }
  return (
    <View  style={{ width: 40,}}>
      <Icon name='share-alt' size={25} color='#999'
        onPress={userShare}
      />
    </View>
  )
}

export default ShareCom

const styles = StyleSheet.create({})